
<?php

header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:OPTIONS, GET, POST'); // 允许option，get，post请求
header('Access-Control-Allow-Headers:*');
// header('Access-Control-Allow-Headers:x-requested-with, content-type'); // 允许x-requested-with请求头

$url_referer = isset($_REQUEST['referer']) ? $_REQUEST['referer'] : '';
$http_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';

header('Content-Type: text/html; charset=UTF-8');
?> 

 
</head> 
 

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  $title = isset($_POST['title']) ? $_POST['title'] : null;
  $username = isset($_POST['name']) ? $_POST['name'] : null;
  $useremail = isset($_POST['email']) ? $_POST['email'] : null;
  $userinquiry = isset($_POST['content']) ? $_POST['content'] : null;
  $userphone = isset($_POST['phone']) ? $_POST['phone'] : null;
  $usercountry = isset($_POST['country']) ? $_POST['country'] : null;
  $useraddress = isset($_POST['address']) ? $_POST['address'] : null;
  $fromcompany = isset($_POST['from_company']) ? $_POST['from_company'] : null;
  $company = isset($_POST['company']) ? $_POST['company'] : null;

  $materials = isset($_POST['materials']) ? $_POST['materials'] : null;
  $application = isset($_POST['application']) ? $_POST['application'] : null;
  $capacity = isset($_POST['capacity']) ? $_POST['capacity'] : null;
  $products = isset($_POST['products']) ? $_POST['products'] : null;
  $useplace = isset($_POST['useplace']) ? $_POST['useplace'] : null;

  $imtype = isset($_POST['imtype']) ? $_POST['imtype'] : null;
  $imvalue = isset($_POST['imvalue']) ? $_POST['imvalue'] : null;

  $timezone_offset = isset($_POST['timezone_offset']) ? $_POST['timezone_offset'] : null;

  $id = isset($_POST['id']) ? $_POST['id'] : null;

  $servertime = date('Y年m月d日 H:i:s'); //date("Y-m-d" H:i:s); date('Y年m月d日 H:i:s');

  //额外的字段可以在这儿添加
  $metadata = array(
    'materials' => $materials,
    'application' => $application,
    'capacity' => $capacity,
    'products' => $products,
    'useplace' => $useplace,
    'imtype' => $imtype,
    'imvalue' => $imvalue,
    'company' => $company,
    'timezone_offset' => $timezone_offset
  );

};




$ip = $_SERVER['REMOTE_ADDR'] . "-" . $_SERVER['HTTP_X_FORWARDED_FOR'] . "<br>" . $_SERVER['HTTP_CLIENT_IP'];




//$title, $username, $useremail, $userinquiry, $userphone, $usercountry, $useraddress, $fromcompany,  date('Y-m-d H:i:s') ."<hr><br>". 
$string = "name:" . $username . "<Br>E-mail:" . $useremail . "<Br> inquiry:" . $userinquiry . "<Br> company:" . $company . "<Br> <Br> <Br> <Br> tel/whatsapp:" . $userphone . "<Br> link  " . $http_referer . "<Br> ip  " . $ip;

//echo ("$string");


?>
<!-- 判断字段 -->
<?PHP
$pattern = "/^[\w\-]+(\.[\w\-]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*(\.[a-zA-Z]{2,})$/";

if (!preg_match($pattern, $useremail )) {
  echo " Please confirm the correct email address" ;
    exit() ;
}  

$iqstr=strlen ($userinquiry) ;  

if 
 ( $iqstr >580 ) 

{ 
echo   "<h3> You are robot, CLOSE</h3>"; 
 
exit() ;
} 

if($iqstr <=0 )  //开始判断是够为空  
{ 
echo "<h3> input message <br> "; 
 
exit() ;
} 



?>


<body> 


</body>